package pe.com.certicom.moviles.model.dao;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import pe.com.certicom.moviles.model.beans.PeriodoFacturacion;
import pe.com.certicom.moviles.model.beans.PeriodoFacturacionExample;
import pe.com.certicom.moviles.model.beans.ReporteConsolidado;

import com.ibatis.sqlmap.client.SqlMapClient;
import pe.com.certicom.moviles.model.beans.PeriodoFacturacionKey;

@Repository
public class PeriodoFacturacionDAOImpl extends SqlMapClientDaoSupport implements PeriodoFacturacionDAO {

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public PeriodoFacturacionDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int countByExample(PeriodoFacturacionExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"periodo_facturacion.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int deleteByExample(PeriodoFacturacionExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"periodo_facturacion.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int deleteByPrimaryKey(PeriodoFacturacionKey key) {
		int rows = getSqlMapClientTemplate().delete(
				"periodo_facturacion.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public void insert(PeriodoFacturacion record) {
		getSqlMapClientTemplate().insert(
				"periodo_facturacion.ibatorgenerated_insert", record);
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public void insertSelective(PeriodoFacturacion record) {
		getSqlMapClientTemplate().insert(
				"periodo_facturacion.ibatorgenerated_insertSelective", record);
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	@SuppressWarnings("unchecked")
	public List<PeriodoFacturacion> selectByExample(
			PeriodoFacturacionExample example) {
		List<PeriodoFacturacion> list = getSqlMapClientTemplate().queryForList(
				"periodo_facturacion.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public PeriodoFacturacion selectByPrimaryKey(PeriodoFacturacionKey key) {
		PeriodoFacturacion record = (PeriodoFacturacion) getSqlMapClientTemplate()
				.queryForObject(
						"periodo_facturacion.ibatorgenerated_selectByPrimaryKey",
						key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int updateByExampleSelective(PeriodoFacturacion record,
			PeriodoFacturacionExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"periodo_facturacion.ibatorgenerated_updateByExampleSelective",
				parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int updateByExample(PeriodoFacturacion record,
			PeriodoFacturacionExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"periodo_facturacion.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int updateByPrimaryKeySelective(PeriodoFacturacion record) {
		int rows = getSqlMapClientTemplate()
				.update("periodo_facturacion.ibatorgenerated_updateByPrimaryKeySelective",
						record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	public int updateByPrimaryKey(PeriodoFacturacion record) {
		int rows = getSqlMapClientTemplate().update(
				"periodo_facturacion.ibatorgenerated_updateByPrimaryKey",
				record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table periodo_facturacion
	 * @ibatorgenerated  Sun May 26 11:20:40 COT 2013
	 */
	private static class UpdateByExampleParms extends PeriodoFacturacionExample {
		private Object record;

		public UpdateByExampleParms(Object record,
				PeriodoFacturacionExample example) {
			super(example);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}

	@Autowired
	public void createSqlMapClient(SqlMapClient sqlMapClient){
	   setSqlMapClient(sqlMapClient);
	}

	@Override
	public int cantidadRango(PeriodoFacturacion p) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"periodo_facturacion.cantidadRango", p);
		return count;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ReporteConsolidado> reporteConsolidadoCentroCosto(
			HashMap<String, Object> parametros) {
		List<ReporteConsolidado> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.reporteConsolidadoCentroCosto", parametros);
		return list;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ReporteConsolidado> reporteConsolidadoProveedor(
			HashMap<String, Object> parametros) {
		List<ReporteConsolidado> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.reporteConsolidadoProveedor", parametros);
		return list;
	}

	@Override
	public List<String> listarPeriodosCerrados(
			HashMap<String, Object> parametros) {
		List<String> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.listarPeriodosCerrados", parametros);
		return list;
	}

	@Override
	public List<ReporteConsolidado> reporteDetalladoCostos(
			HashMap<String, Object> parametros) {
		List<ReporteConsolidado> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.reporteDetalladoCostos", parametros);
		return list;
	}

	@Override
	public List<String> listarPeriodos(HashMap<String, Object> parametros) {
		List<String> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.listarPeriodos", parametros);
		return list;
	}

	@Override
	public List<ReporteConsolidado> reporteDetalladoCostosFechas(
			HashMap<String, Object> parametros) {
		List<ReporteConsolidado> list = getSqlMapClientTemplate().queryForList("periodo_facturacion.reporteDetalladoCostosFechas", parametros);
		return list;
	}
}